<?php

namespace app\common\service;

/**
 * 7号仓的信息
 * @author xiongjingyang 2018-11-2
 */
class WarehouseService
{

    /**
     * 获取7号仓的入库数据
     * @author zhangbin
     * @param int $purchase 采购单数组
     * @return array
     */
    static public function getWarehouse($purchase=[],$field='*',$key='')
    {
        $list=[];
        $field.=',concat(purchaseorders_id,"_",sku) as po_sku';
        $condition=[];
        if(is_array($purchase)){
            $condition['purchaseorders_id']=["in",$purchase];
        }else if(!empty($purchase)){
            $condition['purchaseorders_id']=$purchase;
        }
        $condition["warehouseid"]=7;
        $db=\think\Db::connect('newerp')->table('warehouseorders')->field($field)->where($condition);
       $result=$db->select();
       if($result){
           foreach($result as $value){
               $list[$value[$key]][]=$value; 
           }
       }
       return $list;
    }
}
